package service.impl;

import service.UserService;
import bean.User;
import dao.UserDao;

public class UserServiceImpl implements UserService {
	private UserDao userDao;
	@Override
	public User login(User user) {
		User u=userDao.findUser(user);
		return u;
	}

	@Override
	public boolean modifyUser(User user) {
		return userDao.modifyUser(user);
	}

	@Override
	public boolean deleteUser(User user) {
		return userDao.deleteUser(user);
	}

	public void setUserDao(UserDao userDao) {
		this.userDao = userDao;
	}

	public UserDao getUserDao() {
		return userDao;
	}

	@Override
	public boolean register(User user) {
		if(userDao.findUserByUsername(user.getUsername())!=null)
			return false;
		else{
			userDao.addUser(user);
			return true;
		}
	}

	@Override
	public User viewUserById(int id) {
		User u=userDao.findUserById(id);
		return u;
	}

}
